<?php 
$objSess->setReqSV('rcom', 'anagCamp', 'anag');
if ($codMenu=='rcom' || $bAllMenuOpen) {  
// =================  menu' attivo ==============
	$contaRigheMenu += 5;
   $sStyleX = "padding:3px 0px 3px 0px;";
   if ($codMenu=='rcom') {
      $cltit = 'tit1';
      $fgcol = OVF_COLORE_TESTO;
      $bgcol = OVF_COLORE_SFONDO;
   } else {
      $cltit = 'lab1';
      $fgcol = '444444';
      $bgcol = 'dddddd';
   }
?>
<script type="text/javascript">
<!--
function clickAnag() {
	location.href="<?=OVF_URL_ROOT?>/app/rcom/anag/anagList.php?anagCamp=anag&xsn=<?=XSN?>";
}
function clickCamp() {
	location.href="<?=OVF_URL_ROOT?>/app/rcom/camp/campList.php?anagCamp=camp&xsn=<?=XSN?>";
}
//-->
</script>
<?php 
	echo getHtmlForm('formRelCom');
	echo getHtmlHidden('xsn');
	if ($objSess->getSV('rcom','anagCamp')=='anag') { // menu' anagrafiche
		if ($objSess->getSV('rcom','idAnag')==0) {
			menuRcomAnagList($cltit,$fgcol,$bgcol);
		} else {
			menuRcomAnagSez($cltit,$fgcol,$bgcol);
		}
	} else {	// menu' campagne
		menuRcomCamp($cltit,$fgcol,$bgcol);
	}
	echo "\n</form>\n";
} else { 
// =============== menu disattivo ============
	$contaRigheMenu += 2;
	if ($objSess->getSV('rcom','anagCamp')=='camp') {
		if ($objSess->getSV('rcom','idCamp')==0) {
			$sHref = OVF_URL_ROOT."/app/rcom/camp/campList.php?xsn=".XSN;
		} else {
			$sHref = OVF_URL_ROOT."/app/rcom/camp/campView.php?xsn=".XSN;
		}
	} else {
		if ($objSess->getSV('rcom','idAnag')==0) {
			$sHref = OVF_URL_ROOT."/app/rcom/anag/anagList.php?xsn=".XSN;
		} else {
			$sHref = OVF_URL_ROOT."/app/rcom/anag/anagView.php?xsn=".XSN;
		}
	}
?>
<div class='lab1' style='padding:1px;margin-bottom:2px;'>
	<div class='lab1' style='padding:2px;'>
	<a class='lab1' href="<?=$sHref?>">
	<?=getHtmlImgGen('Relazioni', 140, 20, 'dddddd', '000000', 12)?></a>
	</div>
</div>
<?php 
}
// ============================================
function menuRcomAnagList($cltit,$fgcol,$bgcol) {
	global $objSess, $objDB;
	$aCodList = array();
	$sSql = "SELECT DISTINCT cod_list FROM ovf_campi_list "
				." WHERE tipo_list = 'anagraf' ORDER BY cod_list ";
	$objDB->query($sSql,'selCodList');
	while($acX = $objDB->fetch('selCodList')) {
		$aCodList[$acX['cod_list']] = $acX['cod_list'];
	}
	if (!isset($aCodList[reqVar('codList')])) {
		unset($_REQUEST['codList']);
	}
	reset($aCodList);
	$objSess->setReqSV('anagList', 'codList', key($aCodList));
	$sHref = OVF_URL_ROOT."/app/rcom/anag/anagList.php?xsn=".XSN;
?>
<div class='<?=$cltit?>' style='text-align:left;padding:1px 1px 0px 1px;background-color:<?=$bgcol?>;margin-bottom:0px;'>
	<div class='<?=$cltit?>' style='padding:2px;'>
		<a class='<?=$cltit?>' href="<?=OVF_URL_ROOT."/app/rcom/anag/anagList.php?xsn=".XSN?>">
		<?=getHtmlImgGen('Relazioni', 140, 20, $bgcol, $fgcol, 12)?></a>
	</div>
	<div class='cmd1' style='padding:5px 0px 8px 5px;background-color:#ffffff;'>
		<div class='cmd1' style='padding:3px 0px 3px 0px;'>
			<a class='cmd1' href="<?=OVF_URL_ROOT?>/app/rcom/anag/anagIns.php?xsn=<?=XSN?>"><?=_t('nuova anagrafica')?></a>
		</div>
		<br/>
<?
	$htmlTipoLista = "<a href='#' onClick='formRelCom.submit();' class='cmd1'>"._t('Tipo lista').":</a><br/>";
	$aOpt1 = array("onChange"=>"formRelCom.submit();");
	$htmlTipoLista .= "&nbsp;&nbsp;&nbsp;".getHtmlSelect('codList',$aCodList,'@REQ',$aOpt1);
	$htmlRicAvanz = "<a class='cmd1' href=\"".OVF_URL_ROOT."/app/rcom/rice/ricercaSet.php?xsn=".XSN."\">"
		._t('ricerca avanzata')."</a>\n";
?>
		<div class='cmd1' style='padding:3px 0px 3px 0px;'>
			<?php echo $htmlTipoLista;?>
		</div>
		<br/>
		<div class='cmd1' style='padding:3px 0px 3px 0px;'>
			<?php echo $htmlRicAvanz;?>
		</div>
	</div>
</div>
<?php 
		$sStileC = "color:#444444;background-color:#dddddd;";
		$sStileA = "color:".$fgcol.";background-color:".$bgcol.";";
		$sStileZ = "text-align:center;font-size:9pt;font-weight:bold;cursor:pointer;";
?>
<table cellspacing='1' cellpadding='2' width='100%' class='<?=$cltit?>' style="margin-bottom:2px;">
	<tr>
		<td onClick="clickAnag();" style='<?=$sStileA.$sStileZ?>' width='33%'><?=_t('ANAGRAFE')?></td>
		<td onClick="clickCamp();" style='<?=$sStileC.$sStileZ?>' width='33%'><?=_t('CAMPAGNE')?></td>
	</tr>
</table>
<?php 
}

// ============================================
function menuRcomAnagSez($cltit,$fgcol,$bgcol) {
	global $objSess, $objDB;
	$sHref = OVF_URL_ROOT."/app/rcom/anag/anagView.php?xsn=".XSN;
   $idAnag = $objSess->getSV('rcom','idAnag');
?>
<div class='<?=$cltit?>' style='text-align:left;padding:1px 1px 0px 1px;background-color:<?=$bgcol?>;margin-bottom:0px;'>
	<div class='<?=$cltit?>' style='padding:2px;'>
		<a class='<?=$cltit?>' href="<?=OVF_URL_ROOT."/app/rcom/anag/anagView.php?id=$idAnag&xsn=".XSN?>">
		<?=getHtmlImgGen('Relazioni', 140, 20, $bgcol, $fgcol, 12)?></a>
	</div>
	<div class='cmd1' style='padding:5px 0px 8px 5px;background-color:#ffffff;'>
      <div class='cmd1' style='padding:3px 0px 3px 0px;'>
         <a class='cmd1' href="<?=OVF_URL_ROOT."/app/rcom/anag/anagView.php?idAnag=".$idAnag."&xsn=".XSN?>"><?=_t('scheda anagrafica')?></a>
      </div>
      <!--div class='cmd1' style='padding:3px 0px 3px 0px;'>
         <a class='cmd1' href="<?=OVF_URL_ROOT."/app/rcom/refe/refeList.php?idAnag=".$idAnag."&asez=referent&xsn=".XSN?>"><?=_t('referenti')?></a>
      </div-->
      <div class='cmd1' style='padding:3px 0px 3px 0px;'>Sezioni:</div>
      <div class='cmd1' style='padding:3px 0px 3px 0px;'>
         - <a class='cmd1' href="<?=OVF_URL_ROOT."/app/rcom/cont/contList.php?idAnag=".$idAnag."&xsn=".XSN?>"><?=_t('contatti')?></a>
      </div>
      <div class='cmd1' style='padding:3px 0px 3px 0px;'>
         - <a class='cmd1' href="<?=OVF_URL_ROOT."/app/rcom/docu/docuList.php?idAnag=".$idAnag."&xsn=".XSN?>>"><?=_t('documenti')?></a>
      </div>
<?
   $htmlSezioni = '';
	$sSql = "SELECT * FROM ovf_anag_sez ORDER BY seq,descr ";
	$objDB->query($sSql,'selasez');
	$aAsez = array();
	while($acX = $objDB->fetch('selasez')) {
		$aAsez[] = $acX;
	}	
	foreach ($aAsez as $kX => $aX) {
	   $htmlSezioni .= "<div class='cmd1' style='padding:3px 0px 3px 0px;'>\n";
		if ($aX['tipo_sez']=='ext') {
			$htmlSezioni .= "- <a class='cmd1' href=\"".$aX['url_ext']."?idAnag=".reqVar('idAnag')
				."&xsn=".XSN."\" target='_blank'>".$aX['descr']."</a>\n";
		} else {
			$htmlSezioni .= "- <a class='cmd1' href=\"".OVF_URL_ROOT."/app/rcom/asez/asezList.php?idAnag=".reqVar('idAnag')
				."&asez=".$aX['cod_sez']."&xsn=".XSN."\">".$aX['descr']."</a>\n";
		}
      $htmlSezioni .= "</div>\n";
	}
   echo $htmlSezioni;
?>
      <div class='cmd1' style='padding:3px 0px 3px 0px;'>
         <a class='cmd1' href="<?=OVF_URL_ROOT?>/app/rcom/anag/anagList.php?xsn=<?=XSN?>"><?=_t('lista anagrafiche')?></a>
      </div>
      <div class='cmd1' style='padding:3px 0px 3px 0px;'>
         <a class='cmd1' href="<?=OVF_URL_ROOT?>/app/rcom/anag/anagIns.php?xsn=<?=XSN?>"><?=_t('nuova anagrafica')?></a>
      </div>
	</div>
</div>
<?php 
		$sStileC = "color:#444444;background-color:#dddddd;";
		$sStileA = "color:#$fgcol;background-color:#$bgcol;";
		$sStileZ = "text-align:center;font-size:9pt;font-weight:bold;cursor:pointer;";
?>
<table cellspacing='1' cellpadding='2' width='100%' class='<?=$cltit?>' style="margin-bottom:2px;">
	<tr>
		<td onClick="clickAnag();" style='<?=$sStileA.$sStileZ?>' width='33%'><?=_t('ANAGRAFE')?></td>
		<td onClick="clickCamp();" style='<?=$sStileC.$sStileZ?>' width='33%'><?=_t('CAMPAGNE')?></td>
	</tr>
</table>
<?php 
}

function menuRcomCamp($cltit,$fgcol,$bgcol) {
	global $objSess, $objDB;
	$aCodList = array();
	$sSql = "SELECT DISTINCT cod_list FROM ovf_campi_list "
				." WHERE tipo_list = 'campagne' ORDER BY cod_list ";
	$objDB->query($sSql,'selCodList');
	while($acX = $objDB->fetch('selCodList')) {
		$aCodList[$acX['cod_list']] = $acX['cod_list'];
	}
	if (!isset($aCodList[reqVar('codList')])) {
		unset($_REQUEST['codList']);
	}
	reset($aCodList);
	$objSess->setReqSV('campList', 'codList', key($aCodList));
	if ($objSess->getSV('rcom','idCamp')==0) {
		$sHref = OVF_URL_ROOT."/app/rcom/camp/campList.php?xsn=".XSN;
	} else {
		$sHref = OVF_URL_ROOT."/app/rcom/camp/campView.php?xsn=".XSN;
	}
?>
<div class='<?=$cltit?>' style='text-align:left;padding:1px 1px 0px 1px;background-color:<?=$bgcol?>;margin-bottom:0px;'>
	<div class='<?=$cltit?>' style='padding:2px;'>
		<a class='<?=$cltit?>' href="<?=OVF_URL_ROOT."/app/rcom/camp/campIns.php?xsn=".XSN?>">
		<?=getHtmlImgGen('Relazioni', 140, 20, $bgcol, $fgcol, 12)?></a>
	</div>
	<div class='cmd1' style='padding:5px 0px 8px 5px;background-color:#ffffff;'>
		<div class='cmd1' style='padding:3px 0px 3px 0px;'>
			<a class='cmd1' href="<?=OVF_URL_ROOT?>/app/rcom/camp/campIns.php?xsn=<?=XSN?>"><?=_t("nuova campagna")?></a>
		</div>
		<br/>
		<div class='cmd1' style='padding:3px 0px 3px 0px;'>
			<?php 
			echo "<a href='#' onClick='formRelCom.submit();' class='cmd1'>"._t("Tipo lista").":</a><br/>";
			$aOpt1 = array("onChange"=>"formRelCom.submit();");
			echo "&nbsp;&nbsp;&nbsp;".getHtmlSelect('codList',$aCodList,'@REQ',$aOpt1);
			?>
		</div>
		<br/>
		<div class='cmd1' style='padding:3px 0px 3px 0px;'>
			<a class='cmd1' href="javascript:alert('-- to do --');//<?=OVF_URL_ROOT?>/app/rcom/camp/campList.php?xsn=<?=XSN?>"><?=_t("ricerca avanzata")?></a>
		</div>
	</div>
</div>
<?php 
      $sStileC = "color:#$fgcol;background-color:#$bgcol;";
      $sStileA = "color:#444444;background-color:#dddddd;";
		$sStileZ = "text-align:center;font-size:9pt;font-weight:bold;cursor:pointer;";
?>
<table cellspacing='1' cellpadding='2' width='100%' class='<?=$cltit?>' style="margin-bottom:2px;">
	<tr>
		<td onClick="clickAnag();" style='<?=$sStileA.$sStileZ?>' width='33%'><?=_t("ANAGRAFE")?></td>
		<td onClick="clickCamp();" style='<?=$sStileC.$sStileZ?>' width='33%'><?=_t("CAMPAGNE")?></td>
	</tr>
</table>
<?php 
}